import {mapGetters} from 'vuex';

export default {
    data() {
        return {
            filters: {
                positionId: '',
                date: ''
            },
            options: [],
        }
    },
    computed: {
        ...mapGetters([
            'originalDataList',
            'originalDataPage',
            'riskPositionList'
        ])
    },
    watch: {},
    components: {},
    mounted() {
        this.$store.dispatch('getParasRiskLogList', {}).then((res) => {
            for (let key in res) {
                let childrenArr = []
                res[key].forEach(item => {
                    childrenArr.push({
                        value: item.positionId,
                        label: item.position
                    })
                });
                this.options.push({value: key, label: key, children: childrenArr});
            }
        });
    },
    methods: {
        handleChange: function (value) {
            if (value.length > 1) {
                this.filters.positionId = value[1];
            } else {
                this.filters.positionId = '';
            }
        },
        getAllDataOpt: function () {
            this.$store.dispatch('getOriginalDataList', {...this.filters});
        },

        handleCurrentChange(val) {
            this.originalDataPage.page = val - 1;
            this.getAllDataOpt();
        },
        handleSizeChange(val) {
            this.originalDataPage.page = 0;
            this.originalDataPage.rows = val;
            this.getAllDataOpt();
        },
        handleSearch() {
            this.originalDataPage.page = 0;
            this.getAllDataOpt();
        }
    }
}
